home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 October: Windmill on DISC / ADC Developer CD (1993-10) (''Windmill On DISC'')_iso / Dev.CD Oct 93.iso / Utilities / Installer v3.4.3 / Examples - Installer 3.4 / Installing Fonts / InstallFont.r < prev    next >
Encoding:
Text File  |  1993-06-15  |  14.9 KB  |  397 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *    Apple Macintosh Developer Technical Support
  4.  *
  5.  *  Installer 3.4 sample: installing a font resource into the appropriate place
  6.  *
  7.  *    File:        InstallFont.r -    Rez Source
  8.  *
  9.  *    by:            Rich Kubota
  10.  *    modified:    12/1/92 rrk Include sample action atom to check for system 7.1 and
  11.  *                            pre 7.1 system file.
  12.  *                3/22/93 rrk Corrected the sample to install to the Times files
  13.  *                            instead of the New York font file.
  14.  *
  15.  *    Copyright © 1991 Apple Computer, Inc.
  16.  *    All rights reserved.
  17.  *
  18.  *------------------------------------------------------------------------------
  19.  * This sample installs the "Times" font resource, supplied with System 7.0.1, into
  20.  * the appropriate place: the Font Folder under System 7.1 or into the System file
  21.  * for System 7.0.1 and earlier.  This sample demonstrate the use of the 'inff' 
  22.  * Font Family Resource Atom.
  23.  * It allows for custom installation of fonts.
  24.  *
  25.  * Note: For installation under System 7.1, the script needs to install the font into
  26.  * the Font folder by using the new Folder Manager designator 'font'.  This means that
  27.  * the script needs to determine which system is present and act accordingly.  The font
  28.  * resource can still be installed directly into the 7.1 System file.  Under 7.1, it is
  29.  * preferable to install fonts to the Font folder.  Fonts installed into the System file
  30.  * have priority use in case of name conflicts.
  31.  *
  32.  * The reverse issue of installing fonts into the Fonts folder under 7.0.1 and earlier
  33.  * IS a problem.  In such case, fonts will not be recognized.  Easy install rules
  34.  * help to keep the user from installing the font in the wrong place.  For custom
  35.  * installation, this script includes a pre-installation action
  36.  * atom to check the version of the System file, should the 7.1 font package be selected.
  37.  * If the system is earlier, the code resource alerts the user that the target
  38.  * volume has an incompatible system for installing fonts to the Font folder.  
  39.  * Unfortunately, Installer 3.4 installs fonts to the Font folder if the "special-font"
  40.  * designator is used for System 7.0.1.
  41.  *
  42.  * IMPORTANT NOTE:  There exists a known BUG with Installer v3.4 when installing
  43.  * font resources.  This problem is fixed with Installer 3.4.3.
  44.  *
  45.  * The problem occurs when a font resource already exists on a 
  46.  * System 7.0.1 or earlier system with the same ID as the one to be installed, BUT
  47.  * with a different name.  Under such situation, the Installer remaps the new FOND 
  48.  * ID as it should, however the remapping begins with ID 0.  This normally results
  49.  * in a remap to FOND ID 1 - a System reserved FOND ID.  The result is that the
  50.  * font will never be recognized.  We have not found this problem to corrupt the
  51.  * System.  This problem will be corrected in a future release of the Installer.  
  52.  * The same problem exists in Installer 3.3.  A similar problem exists with 
  53.  * Installer 3.2 except that no remapping takes place and there will exist FOND
  54.  * resources with the same resource ID.
  55.  *----------------------------------------------------------------------------*/
  56.  
  57. #ifdef INSTRUCTIONS
  58.  
  59.  
  60. # To create the installation disk
  61. # 1. Name the floppy disk "Font Installer".
  62. # 2. Copy Installer 3.4 onto the floppy.
  63. # 3. Copy the Times font suitcase supplied in System 7.1 to the floppy.
  64. # 4. Rez and ScriptCheck 3.4b2 this script, and copy to the floppy.
  65.  
  66. * Note that the CheckTgtSysVer code resource has already been compiled for you.  You can 
  67. * implement your own alterations to the code resource by following the make instructions
  68. * presented in the file CheckTgtSysVer.c
  69.  
  70. # You can build and complete the script with the following lines:
  71. #    Note: set up floppies with the appropriate names and contents before running scriptcheck
  72. #    or set up folders with the same names and contents as the floppies
  73. #    put these folders in the same folder as the script or at the root directory of same disk
  74.  
  75.     rez -o "Install Font Script" -t 'bbkr' -c 'bbkr' "InstallFont.r"
  76.     setfile -a i "Install Font Script"        #mark Inited
  77.     scriptcheck -p "Install Font Script"
  78.  
  79. #endif
  80.  
  81.  
  82. #include "Types.r"                    /* for the ICON and Action Atom code resources */
  83. #include "InstallerTypes.r"
  84. #include "CheckTgtSysVer.h"
  85.  
  86.  
  87. /* put a 1 in the creation date field of source 'infs' to have ScriptCheck set date */
  88. #define kDateNotChecked        0
  89. #define kTimesFontSize            287500  /* file is 287254 bytes + buffer */
  90.                                 /* This figure is derived from the Times font supplied */
  91.                                 /* with System 7.1. */
  92.  
  93. /* Definitions for the rules */
  94. #define fontRule71            1000
  95. #define fontRulePre71        1001
  96. #define noSystem            1002
  97.  
  98. /* Defines for the file spec atoms.  These are specifications for source and destination files */
  99. #define fsSourceFont        2000
  100. #define fsTargetSystem        2001
  101. #define fsTargetFontFolder    2002
  102.  
  103. /* This is the name of the source disk */
  104. #define FontDisk "Font Installer:"
  105.  
  106. /* where we want to install our Font. */
  107. #define TargetPath71 "special-font:"    /* Indicate that we want to install the font to
  108.                                         the Font folder for System 7.1.
  109.                                     */
  110. #define TargetPathPre71 "special-macs:"    /* Indicate that we want to install the font to
  111.                                         the System file for System 7.0.1 and ealier.
  112.                                     */
  113.  
  114. /* Definition for the packages. */
  115. #define pkTheFont71            3000
  116. #define pkTheFontPre71        3001
  117.  
  118. /* Definition for the font resource atom. */
  119. #define ffTheFont71            4000
  120. #define ffTheFontPre71        4001
  121.  
  122. /* Definition for the package comment resource */
  123. #define cmtTheFont71        5000
  124. #define cmtTheFontPre71        5001
  125. #define iconTheFont            6000
  126.  
  127. /* Definitions for the action atom resources */
  128. #define aaCheckFor71        7000
  129. #define aaCheckForPre71        7001
  130.  
  131. /* 'inaa' code resource definition */
  132. #define        aaCodeID        10000
  133.  
  134. /* December 1, 1992 is the current release date I put in 'icmt' rsrcs. ScriptCheck will convert */
  135. /* this value to a LongInt seconds value needed by the Installer. */
  136. #define currentReleaseDate    12011992        
  137. #define currentVersion        102     /* Version 1.0.2 goes in the 'icmt' rsrc */
  138.  
  139.  
  140. /************************** Easy Install Rule resources **********************************/
  141. resource 'infr' (1) {
  142.     format0  {{
  143.         pickFirst,    {fontRule71, fontRulePre71, noSystem}     /* Select the Font rule */
  144.     }};
  145. };
  146.  
  147. resource 'inrl' (fontRule71) {
  148.     format0 {{
  149.         checkFileVersion{fsTargetSystem, 7, 0x10, release, 0},
  150.         addUserDescription {"Click Install button to install\n"},    
  151.                                             /* message to appear in Easy Install screen */
  152.         addUserDescription {"• the Times Font in the Font Folder\n"}, /* 2nd line of message */
  153.         addPackages {{pkTheFont71}}            /* installing the font package */
  154.     }};
  155. };
  156.  
  157. resource 'inrl' (fontRulePre71) {
  158.     format0 {{
  159.         checkFileVersion{fsTargetSystem, 0, 0x0, release, 0},
  160.         addUserDescription {"Click Install button to install\n"},    
  161.                                             /* message to appear in Easy Install screen */
  162.         addUserDescription {"• the Times Font into the System File\n"}, /* 2nd line of message */
  163.         addPackages {{pkTheFontPre71}}        /* installing the font package */
  164.     }};
  165. };
  166.  
  167. resource 'inrl' (noSystem) {
  168.     format0 {{
  169.         reportVolError {"There is no System on volume ^0."},
  170.     }};
  171. };
  172.  
  173. /***************************** Package Resources ************************************************/
  174. resource 'inpk' (pkTheFont71)     {    /* This package could include other atoms */
  175.     format0 {
  176.         showsOnCustom,                 /* Package appears in the Custom Install display */
  177.         removable,                    /* Package can be removed */
  178.         dontForceRestart,            /* not necessary to reboot in this case */
  179.         cmtTheFont71,                 /* package's 'icmt' resource id */
  180.         kTimesFontSize,                /* Package size must be entered manually */
  181.                                     /* ScriptCheck wont do this for us.  Note, make sure you
  182.                                         use ScriptCheck v3.4b2 or greater.  
  183.                                     */
  184.         "Install Times Font for Sys 7.1", { /* package name for package that shows on custom */
  185.             'inaa', aaCheckFor71,
  186.             'inff', ffTheFont71;
  187.         }
  188.     }
  189. };
  190.  
  191. resource 'inpk' (pkTheFontPre71) {    /* This package could include other atoms */
  192.     format0 {
  193.         showsOnCustom,                 /* Package appears in the Custom Install display */
  194.         removable,                    /* Package can be removed */
  195.         dontForceRestart,            /* not necessary to reboot in this case */
  196.         cmtTheFontPre71,             /* package's 'icmt' resource id */
  197.         kTimesFontSize,                /* Package size must be entered manually */
  198.                                     /* ScriptCheck wont do this for us.  Note, make sure you
  199.                                         use ScriptCheck v3.4b2 or greater.  
  200.                                     */
  201.         "Install Times Font for Sys 7.0.1 and earlier", { /* package name for package that shows on custom */
  202.             'inaa', aaCheckForPre71,
  203.             'inff', ffTheFontPre71;
  204.         }
  205.     }
  206. };
  207.  
  208. /***************************** Comments ************************************************/
  209. resource 'icmt' (cmtTheFont71) {
  210.     currentReleaseDate,
  211.     currentVersion,
  212.     iconTheFont,
  213.     "This package installs the Times Font into the System 7.1 Font Folder. "
  214. };
  215.  
  216. resource 'icmt' (cmtTheFontPre71) {
  217.     currentReleaseDate,
  218.     currentVersion,
  219.     iconTheFont,
  220.     "This package installs the Times Font into the System File for System 7.0.1 and earlier."
  221. };
  222.  
  223. resource 'ICON' (iconTheFont) {
  224.         $"0430 4000 0A50 A000 0B91 1002 0822 0803"
  225.         $"1224 0405 2028 0209 4010 0111 800C 00A1"
  226.         $"8003 FFC2 7E00 FF04 0100 7F04 0300 1E08"
  227.         $"04E0 000C 08E0 000A 10E0 0009 08C0 0006"
  228.         $"0487 FE04 0288 0104 0188 0084 0088 0044"
  229.         $"0088 0044 0088 00C4 0110 0188 0228 0310"
  230.         $"01C4 04E0 0002 0800 73BF FBEE 4CA2 8A2A"
  231.         $"40AA AAEA 52AA AA24 5EA2 8AEA 73BE FB8E",
  232. };
  233.  
  234.  
  235.  
  236. /********************************************* File Specs *******************************************/
  237. /* Source File Specs */
  238. resource 'infs' (fsSourceFont) {
  239.     'FFIL',                                /* File Type */
  240.     'DMOV',                                /* Creator */
  241.     kDateNotChecked,                    /* ScriptCheck fills in the creation date */
  242.     noSearchForFile,                    /* Do not search the source disk for the file */
  243.     typeCrNeedNotMatch,                    /* file type and creator on source disk must match */
  244.     FontDisk"Times"                        /* Path to the file */
  245. };
  246.  
  247. resource 'infs' (fsTargetSystem) {
  248.     'ZSYS',                                /* File Type */
  249.     'MACS',                                /* Creator */
  250.     0,                                    /* creation date not needed for target file specs */
  251.     noSearchForFile,                    /* Do not search the target disk for the file */
  252.     typeCrNeedNotMatch,                    /* match system 6 or 7 */
  253.     TargetPathPre71"System"                /* destination Path */
  254. };
  255.  
  256. resource 'infs' (fsTargetFontFolder) {
  257.     'FFIL',                                /* File Type */
  258.     'DMOV',                                /* Creator */
  259.     0,                                    /* creation date not needed for target file specs */
  260.     noSearchForFile,                    /* Do not search the target disk for the file */
  261.     typeCrNeedNotMatch,                    /* match system 6 or 7 */
  262.     TargetPath71"Times"                    /* destination Path */
  263. };
  264.  
  265. /*************************************** Font Family Atoms **********************************************/
  266. resource 'inff' (ffTheFont71) {
  267.     format0 {
  268.         deleteWhenRemoving,                /* Delete the resource if remove (option-custom) is clicked    */
  269.         deleteWhenInstalling,             /* delete the target before copying new one */
  270.         copy,                             /* Copy rsrc to destination */
  271.         noTgtRequired,                     /* Target file need not exist on dest to install */
  272.         updateExisting,                 /* replace any preexisting file with the same name */
  273.         copyIfNewOrUpdate,                 /* Copy whether or not target rsrc already exists */
  274.         ignoreProtection,                /* Do it even if the target rsrc is protected */
  275.         srcNeedExist,                    /* Rsrc needs to exist on source disk */
  276.         byName,                            /* use the name to find the source and target rsrc */
  277.         nameMustMatch,                    /* this field is ignored if above is byName */
  278.         fsTargetFontFolder,                /* Target file spec to install rsrc into */
  279.         fsSourceFont,                    /* Source file spec where to get rsrc */
  280.         0x20,                            /* 'FOND' is purgeable */
  281.         kTimesFontSize,                    /* font resource size entered manually */
  282.         20,                                /* Resource ID of Times 'FOND' */
  283.         entireFamily {                    /* all strikes found in FOND to be installed */
  284.         },
  285.         "Times Font",                    /* Atom description */
  286.         "Times"                            /* Font Resource name */
  287.     };
  288. };
  289.  
  290. resource 'inff' (ffTheFontPre71) {
  291.     format0 {
  292.         deleteWhenRemoving,                /* Delete the resource if remove (option-custom) is clicked    */
  293.         dontDeleteWhenInstalling,         /* dont need to delete the target before copying new one */
  294.         copy,                             /* Copy rsrc to destination */
  295.         tgtRequired,                     /* System file need already exist on dest to install */
  296.         updateExisting,                 /* replace any preexisting DA with the same name */
  297.         copyIfNewOrUpdate,                 /* Copy whether or not target rsrc already exists */
  298.         ignoreProtection,                /* Do it even if the target rsrc is protected */
  299.         srcNeedExist,                    /* Rsrc needs to exist on source disk */
  300.         byName,                            /* use the name to find the source and target rsrc */
  301.         nameMustMatch,                    /* this field is ignored if above is byName */
  302.         fsTargetSystem,                    /* Target file spec to install rsrc into */
  303.         fsSourceFont,                    /* Source file spec where to get rsrc */
  304.         0x20,                            /* 'FOND' is purgeable */
  305.         kTimesFontSize,                    /* font resource size entered manually */
  306.         20,                                /* Resource ID of Times 'FOND' */
  307.         entireFamily {                    /* all strikes found in FOND to be installed */
  308.         },
  309.         "Times Font",                    /* Atom description */
  310.         "Times"                            /* Font Resource name */
  311.     };
  312. };
  313.  
  314. /******************************************** Action Atoms ************************************************/
  315.  
  316. resource 'inaa'    (aaCheckFor71) {
  317.     format1 {
  318.         suspendBusyCursors,                /* go back to arrow cursor should alert happen */
  319.         actBefore,                        /* act before the installation occurs */
  320.         dontActOnRemove,                /* dont need to be called on remove */
  321.         actOnInstall,                    /* get called on installation */
  322.         'infn',                            /* code resource type */
  323.         aaCodeID,                        /* code resource ID */
  324.         kSys71,                            /* check for System 7.1 or greater */
  325.         ""
  326.     }
  327. };
  328.  
  329. resource 'inaa'    (aaCheckForPre71) {
  330.     format1 {
  331.         suspendBusyCursors,                /* go back to arrow cursor should alert happen */
  332.         actBefore,                        /* act before the installation occurs */
  333.         dontActOnRemove,                /* dont need to be called on remove */
  334.         actOnInstall,                    /* get called on installation */
  335.         'infn',                            /* code resource type */
  336.         aaCodeID,                        /* code resource ID */
  337.         kSysPre71,                        /* check for System 7.1 or greater */
  338.         ""
  339.     }
  340. };
  341.  
  342.  
  343.  
  344. /* The following resources are required by the CheckTgtSysVer action atom */
  345.  
  346. resource 'STR#' (kErrStrings, purgeable) {
  347.     {
  348.     "There is no blessed system folder on the target volume.  Aborting font installation.";
  349.     "Cannot install this package to System 7.1 or greater.  Aborting font installation.";
  350.     "This package requires System 7.1 or greater.  Aborting font installation.";
  351.     "Unable to verify system version.  Aborting installation.";
  352.     }
  353. };
  354.  
  355. /* this ALRT and DITL are used as an error screen */
  356.  
  357. resource 'ALRT' (rUserAlert, purgeable) {
  358.     {40, 20, 200, 375},
  359.     rUserAlert,
  360.     { /* array: 4 elements */
  361.         /* [1] */
  362.         OK, visible, silent,
  363.         /* [2] */
  364.         OK, visible, silent,
  365.         /* [3] */
  366.         OK, visible, silent,
  367.         /* [4] */
  368.         OK, visible, silent
  369.     }
  370. };
  371.  
  372.  
  373. resource 'DITL' (rUserAlert, purgeable) {
  374.     { /* array DITLarray: 3 elements */
  375.         /* [1] */
  376.         {130, 270, 150, 350},
  377.         Button {
  378.             enabled,
  379.             "OK"
  380.         },
  381.         /* [2] */
  382.         {10, 60, 120, 350},
  383.         StaticText {
  384.             disabled,
  385.             "Error. ^0."
  386.         },
  387.         /* [3] */
  388.         {8, 8, 40, 40},
  389.         Icon {
  390.             disabled,
  391.             0
  392.         }
  393.     }
  394. };
  395.  
  396. INCLUDE    "CheckTgtSysVer.rsrc" 'infn' (10000) AS 'infn' (aaCodeID, $$Attributes);
  397.